using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace G2007.CodeGen.Library.Generator
{
    class PageGenerator
    {

        string[] data;
        Data.Class[] classes;

        Data.Page[] pages;

        public void DoPageWork(string[] data,G2007.CodeGen.Library.Data.Class[] classes)
        {
            this.data = data;
            this.classes = classes;

            string error = "";
            getPages(out error);


            int g = 0xf;
            // now all the pages are generated what can we do now?



        }


        bool getPages(out string error)
        {
            error = "";
            ArrayList al = new ArrayList();
            foreach (string t in data)
            {
                string s = t.Trim();
                if (s.ToUpper().StartsWith("PAGE"))
                {
                    if (s.Split('\t').Length == 3)
                    {
                        Data.Page page=new G2007.CodeGen.Library.Data.Page();
                        string[] split = s.Split('\t');
                        page.PageTitle = split[1];
                        
                        foreach (Data.Class _class in classes)
                        {
                            if (_class.Name.ToUpper().Equals(split[2].ToUpper()))
                            {
                                page.LinkClass = _class;
                                page.GetPageSection(data);
                                al.Add(page);
                                break;
                            }
                        }
                    }
                }
            }
            pages = (Data.Page[])al.ToArray(typeof(Data.Page));
            return true;
        }


    }
}
